#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
@FileName  :main.py 
@desc      :
@Author    :Young
@IDE       :PyCharm
@Time      :2022-10-16 14:39
'''
from DBOperation import *
import sys
from PyQt5 import QtWidgets
from destroy import *  #登录失败
from resign import *  #登录界面
from SerialPortOperation import * #登录成功
from DBOperation import *







import sys
if __name__=='__main__':
    database_init()
    app =  QApplication(sys.argv)
    loginWindow = Ui_ResignWindow()
    loginFailureWindow = Ui_DestroyWindow()
    loginSuccessfulWindow = Pyqt_Serial()

    def futherCheck(loginInfo):
        print("loginInfo", loginInfo)
        account = loginInfo[0]
        password = loginInfo[1]
        if account == "" or password == "":
            #print(2222)
            loginFailureWindow.show()
        else:
            # 在数据库中查询
            result = selectUserByIDNumber(account, password)
            #print("result",result)
            if result:
                #print(1111)
                loginSuccessfulWindow.show(result,True)
                loginWindow.close()
            else:
                loginFailureWindow.show()


    loginWindow.enter.clicked.connect(lambda : loginWindow.returnInfo() \
                                               and futherCheck(loginWindow.returnInfo()))
    loginWindow.show()
    sys.exit(app.exec_())
    close_cursor()


